package com.hh.bidding.service.impl;

import com.hh.bidding.domain.BidTenderQuotation;
import com.hh.bidding.mapper.BidTenderQuotationMapper;
import com.hh.bidding.service.IBidTenderQuotationService;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 招标报价;(bid_tender_quotation)表服务实现类
 * @author : http://www.chiner.pro
 * @date : 2025-9-11
 */
@Service
public class BidTenderQuotationServiceImpl implements IBidTenderQuotationService {
    @Resource
    private BidTenderQuotationMapper bidTenderQuotationMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    public BidTenderQuotation queryById(Integer id){
        return bidTenderQuotationMapper.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param bidTenderQuotation 筛选条件
     * @return 查询结果
     */
    public List<BidTenderQuotation> paginQuery(BidTenderQuotation bidTenderQuotation){
        long total = bidTenderQuotationMapper.count(bidTenderQuotation);
        return bidTenderQuotationMapper.queryAllByLimit(bidTenderQuotation);
    }

    public List<BidTenderQuotation> findAllByHidAndSid(Integer hid, Integer sid){
        return bidTenderQuotationMapper.findAllByHidAndSid(hid,sid);
    }

    public List<BidTenderQuotation> findAllListBySid(Integer sid){
        return bidTenderQuotationMapper.findAllListBySid(sid);
    }

    public BidTenderQuotation findLastQuotationByHidAndSid(Integer hid, Integer sid){
        return bidTenderQuotationMapper.findLastQuotationByHidAndSid(hid,sid);
    }

    /**
     * 新增数据
     *
     * @param bidTenderQuotation 实例对象
     * @return 实例对象
     */
    public int insert(BidTenderQuotation bidTenderQuotation){
        bidTenderQuotation.setCreateTime(DateUtils.getNowDate());
        return bidTenderQuotationMapper.insert(bidTenderQuotation);
    }

    /**
     * 更新数据
     *
     * @param bidTenderQuotation 实例对象
     * @return 实例对象
     */
    public int update(BidTenderQuotation bidTenderQuotation){
        bidTenderQuotation.setUpdateTime(DateUtils.getNowDate());
        return bidTenderQuotationMapper.update(bidTenderQuotation);
    }

    public int updateSorted(BidTenderQuotation bidTenderQuotation){
        bidTenderQuotation.setUpdateTime(DateUtils.getNowDate());
        return bidTenderQuotationMapper.updateSorted(bidTenderQuotation);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    public int deleteById(Integer id){
        return bidTenderQuotationMapper.deleteById(id);
    }
}
